package edu.stanford.bmir.protege.web.client.ui.ontology.stkos.cutter.statistical;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Label;

import edu.stanford.bmir.protege.web.client.project.Project;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.cutter.CuttingResult;

public class StkosCutterStatisticalView extends Composite {
	interface StkosCutterStatisticalViewUiBinder extends
			UiBinder<HTMLPanel, StkosCutterStatisticalView> {
	}

	private static StkosCutterStatisticalViewUiBinder ourUiBinder = GWT
			.create(StkosCutterStatisticalViewUiBinder.class);

	private Project project;

	/** 当前工程 **/

	// 类总数
	@UiField
	protected Label classCount;

	// 已裁切类个数
	@UiField
	protected Label cutterClassNumber;

	// 属性总数
	@UiField
	protected Label propertyCount;

	// 已裁切属性个数
	@UiField
	protected Label cutterPropertyNumber;

	// 个体总数
	@UiField
	protected Label individualCount;

	// 已裁切个体个数
	@UiField
	protected Label cutterIndividualNumber;

	public StkosCutterStatisticalView(Project project) {
		this.project = project;
		HTMLPanel rootElement = ourUiBinder.createAndBindUi(this);
		initWidget(rootElement);
	}

	public void setCuttingResult(CuttingResult result) {
		int totalClassNumber = 0, cutClassNumber = 0, totalPropertyNumber = 0, cutPropertyNumber = 0, totalIndividualNumber = 0, cutIndividualNumber = 0;
		if (result != null) {
			totalClassNumber = result.getTotalClassNumber();
			cutClassNumber = result.getCutClassNumber();
			totalPropertyNumber = result.getTotalPropertyNumber();
			cutPropertyNumber = result.getCutPropertyNumber();
			totalIndividualNumber = result.getTotalIndividualNumber();
			cutIndividualNumber = result.getCutIndividualNumber();
		}
		this.classCount.setText(String.valueOf(totalClassNumber));
		this.cutterClassNumber.setText(String.valueOf(cutClassNumber));
		this.propertyCount.setText(String.valueOf(totalPropertyNumber));
		this.cutterPropertyNumber.setText(String.valueOf(cutPropertyNumber));
		this.individualCount.setText(String.valueOf(totalIndividualNumber));
		this.cutterIndividualNumber
				.setText(String.valueOf(cutIndividualNumber));
	}
}
